package cn.maihe.elg.operation.model.enums;

import java.util.Arrays;

/**
 * @Description
 * @Author SSX
 * @Date 2025/5/21
 */
public enum ResponseCodeEnum {

    SUCCESS("000000", "成功"),
    FAILURE("000400", "失败")
    ;

    private String respCode;
    private String respDesc;

    ResponseCodeEnum(String respCode, String respDesc) {
        this.respCode = respCode;
        this.respDesc = respDesc;
    }

    public String getRespCode() {
        return respCode;
    }

    public String getRespDesc() {
        return respDesc;
    }

    public ResponseCodeEnum resolve(String respCode) {
        return Arrays.stream(values()).filter(v -> v.getRespCode().equals(respCode)).findFirst().orElseThrow(() -> new RuntimeException("未知响应码[" + respCode + "错误]"));
    }
}
